package com.woke.httpupload;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class HttpAssist {  
    private static final String TAG = "uploadFile";  
    private static final int TIME_OUT = 10 * 10000000; //
    private static final String CHARSET = "utf-8"; //
    public static final String SUCCESS = "1";  
    public static final String FAILURE = "0";  
    // ��Ӧ
    private static HttpResponse mHttpResponse = null;
    // ʵ��
    private static HttpEntity mHttpEntity = null;
	private static String result;
  
    public static String uploadFile() { 

    		
    		
    		 // ����һ���������
    	    HttpGet httpGet = new HttpGet("http://www.baidu.com/");
    	    // ����һ��Http�ͻ��˶���
    	    HttpClient httpClient = new DefaultHttpClient();

    	    // ����ʹ��Http�ͻ��˷������󣬲���ȡ��Ӧ����

    	    InputStream inputStream = null;
    	    try
    	    {
    	        // �������󲢻����Ӧ����
    	        mHttpResponse = httpClient.execute(httpGet);
    	        // �����Ӧ����Ϣʵ��
    	        mHttpEntity = mHttpResponse.getEntity();

    	        // ��ȡһ��������
    	        inputStream = mHttpEntity.getContent();

    	        BufferedReader bufferedReader = new BufferedReader(
    	                new InputStreamReader(inputStream));

    	        result = "";
    	        String line = "";

    	        while (null != (line = bufferedReader.readLine()))
    	        {
    	            result += line;
    	        }

    	        // �������ӡ������������LogCat�鿴
    	        System.out.println(result);

    	        // ����������WebView��ʾ
//    	        mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
    	        // ֱ��ʹ��mWebView.loadData(result, "text/html", "utf-8");����ʾ�Ҳ�����ҳ

    	        // ��������ķ�ʽ����������ʾ�����ǱȽϿ��϶��ɼ��ٶ�logo��
//    	        mWebView.loadDataWithBaseURL(null, result, "text/html",
//    	                "utf-8", null);
    	        
    	        // ֱ������URLҲ������ʾҳ�棨���Ǵ�������Ҫ��Ϊ����֤��Ӧ���ص��ַ����Ƿ���ȷ�����Բ����������д��룩
    	        // mWebView.loadUrl("http://www.baidu.com/");
    	    }
    	    catch (Exception e)
    	    {
    	        e.printStackTrace();
    	    }
    	    finally
    	    {
    	        try
    	        {
    	            inputStream.close();
    	        }
    	        catch (IOException e)
    	        {
    	            e.printStackTrace();
    	        }
    	    }
			return ""+result;
    }
    	}

